//
//  JSTAlertView.h
//  KYKJPackDemo
//
//  Created by 01 on 17/4/28.
//  Copyright © 2017年 ???. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef void (^JSTBasicBlock)(void);

@protocol JSTAlertViewDelegate;

@interface JSTAlertView : UIView
{
@private
    UILabel   *_titleLabel;
    UILabel   *_bodyTextLabel;
    UITextView *_bodyTextView;
    UIView    *_customView;
    UIView    *_contentView;
    UIView    *_backgroundView;
    BOOL    _visible;
    BOOL    _dimBackground;
    UIInterfaceOrientation _orientation;
    JSTBasicBlock    _cancelBlock;
    JSTBasicBlock    _confirmBlock;
}

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *bodyTextLabel;
/*!
 是否正在显示
 */
@property (nonatomic, readonly, getter=isVisible) BOOL visible;

/*!
 背景是否有渐变背景, 默认YES
 */
@property (nonatomic, assign) BOOL dimBackground;       //是否渐变背景，默认YES

@property (nonatomic, strong) UIView *contentView;       //是否渐变背景，默认YES

/*!
 背景视图，覆盖全屏的，默认nil
 */
@property (nonatomic, strong) UIView *backgroundView;   //背景view, 可无

/*!
 在点击确认后,是否需要dismiss, 默认YES
 */
@property (nonatomic, assign) BOOL shouldDismissAfterConfirm;

/*!
 文本对齐方式
 */
@property (nonatomic, assign) NSTextAlignment contentAlignment;

@property (nonatomic, weak) id<JSTAlertViewDelegate> delegate;

- (void)setCancelBlock:(JSTBasicBlock)block;

- (void)setConfirmBlock:(JSTBasicBlock)block;

- (id)initWithTitle:(NSString *)title
            message:(NSString *)message
         customView:(UIView *)customView
           delegate:(id <JSTAlertViewDelegate>)delegate
  cancelButtonTitle:(NSString *)cancelButtonTitle
  otherButtonTitles:(NSString *)otherButtonTitle;

- (void)show;

- (void)dismiss;

+ (void)dismissMaskWindow;

+ (JSTAlertView *)getStackTopAlertView;

+ (void)dismissAllAlerts;

@end

@protocol JSTAlertViewDelegate <NSObject>

@optional

- (void)alertView:(JSTAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex;

- (void)alertView:(JSTAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;

- (void)didRotationToInterfaceOrientation:(BOOL)Landscape view:(UIView*)view alertView:(JSTAlertView *)aletView;

@end
